<div>
<h2 style="margin-top: 0;">Zutatenkategorien</h2>
<?php $i=0;
foreach ($this->ingredientCategories as $ingredientCategory){ 
	$i++; 
	if($i!=1) { print ', '; } ?><a href="#<?php print $ingredientCategory->getUniqueName(); ?>"><?php print $ingredientCategory->name; ?></a><?php 
} ?>
<?php foreach ($this->ingredientCategories as $ingredientCategory){ ?>
<h3 id="<?php print $ingredientCategory->getUniqueName(); ?>"
 style="margin-bottom: 0.5em;"><a 
 href="<?php print $this->url(
 array('controller'=>'ingredient-category','action'=>'get','module'=>'website',
 'id'=>$ingredientCategory->getUniqueName())); ?>?format=mobile"><?php 
 print $ingredientCategory->name; ?></a></h3>
<table class="table" style="margin-bottom: 2em;">
	<thead>
		<tr>
			<th>Zutat</th>
			<th>Kalorien</th>
			<th>Preis</th>
		</tr>
	</thead>
	<tbody>
	<?php foreach (Website_Model_IngredientCategory::getIngredientsByCategory($ingredientCategory->id) as $ingredient){ ?>
		<tr>
			<td><a
				href="<?php print $this->url(array('controller'=>'ingredient','action'=>'get','module'=>'website','id'=>$ingredient->getUniqueName())); ?>?format=mobile">
				<?php print $ingredient->name; ?></a> (<?php if($ingredient->getAverageAlcoholLevel()) { print $ingredient->getAverageAlcoholLevel().'&nbsp;%'; } else { print '0&nbsp;%'; } ?>)<?php 
			if($ingredient->getRecipes()) {
				$i=0;
				foreach($ingredient->getRecipes() as $recipe){
					$i++;
				}
				?>, <a
				href="<?php print $this->url(array('controller'=>'ingredient','action'=>'get','module'=>'website','id'=>$ingredient->getUniqueName())); ?>?format=mobile#recipes-list"><?php print $i; ?>
			Rezepte</a><?php
			}
			?><?php 
			$products = Website_Model_Product::productsByIngredientId($ingredient->id);
			if(is_array($products)) {
				$i=0;
				foreach ($products as $product) {
					$i++;
				}
			}
			?>, <a
				href="<?php print $this->url(array('controller'=>'ingredient','action'=>'get','module'=>'website','id'=>$ingredient->getUniqueName())); ?>?format=mobile#products-list"><?php print $i; ?>
			Produkte</a></td>
			<td><?php if($ingredient->getAverageCaloriesKcal()) { print round($ingredient->getAverageCaloriesKcal()/10); ?>&nbsp;kcal<?php } else { print 'k.A.'; } ?></td>
			<td><?php 
			if($ingredient->getAveragePricePerLitre() || $ingredient->getAveragePricePerKilogram()) {
				if($ingredient->getAveragePricePerLitre()) {
					print number_format($ingredient->getAveragePricePerLitre(),2,',','.').'&nbsp;€&nbsp;/&nbsp;l ';
				}
				if($ingredient->getAveragePricePerLitre() && $ingredient->getAveragePricePerKilogram()) {
					print ' bzw. ';
				}
				if($ingredient->getAveragePricePerKilogram()) {
					print number_format($ingredient->getAveragePricePerKilogram(),2,',','.').'&nbsp;€&nbsp;/&nbsp;kg';
				}
			} ?></td>
		</tr>
		<?php } ?>
	</tbody>
</table><?php } ?>
</div>